package com.study.leetcode;
//
public class Solution_142 {
    public ListNode detectCycle(ListNode head) {
        while (head != null) {
            if (head.val == Integer.MAX_VALUE) {
                return head;
            }
            head.val = Integer.MAX_VALUE;
            head = head.next;
        }
        return null;
    }
}
